<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%@include file="/WEB-INF/jsp/include/tags.jsp"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>template - list</title>
	<link rel="stylesheet" type="text/css" href="/css/style.css"/>
	<script type="text/javascript">
	<!--
		function goPage(page) {
			var f = document.templateCriteriaForm;
			f.action = '/template.do';
			f.method = 'get';
			f.elements["mode"].value = "list";
			f.elements["paging.currentPage"].value = page;
			f.submit();
		}
		
		function search() {
			var f = document.templateCriteriaForm;
			f.action = '/template.do';
			f.method = 'get';
			f.elements["mode"].value = "list";
			f.elements["paging.currentPage"].value = 0;
			f.submit();
		}
		
		function goDetail(tplName) {
			var f = document.templateCriteriaForm;
			f.action = '/template.do';
			f.method = 'get';
			f.elements["mode"].value = "detail";
			f.elements["tplName"].value = tplName;
			f.submit();
		}
		
		function goWrite() {
			var f = document.templateCriteriaForm;
			f.action = '/templateWrite.do';
			f.method = 'get';
			f.elements["mode"].value = "write";
			f.submit();
		}
	//-->
	</script>
</head>
<body>
	
	<p><a href="/">home</a></p>
	
	<h1>Template - list</h1>
	
	<form:form commandName="templateCriteria" id="templateCriteriaForm" name="templateCriteriaForm" action="/template.do" method="get">
	<input type="hidden" name="mode"/>
	<form:hidden path="tplName"/>
	<form:hidden path="paging.currentPage"/>
	</form:form>
	
	<div>
		${templateCriteria.paging.totalResults} results. 
	</div>
	
	<table width="800">
		<colgroup width="800">
			<col width="*"/>
			<col width="*"/>
			<col width="*"/>
			<col width="*"/>
		</colgroup>
		<tr>
			<th>tplName</th>
			<th>tplSource</th>
			<th>lastModified</th>
			<th>isDirectory</th>
		</tr>
		<c:forEach var="template" items="${templateList}">
		<tr>
			<td>
				<a href="javascript:goDetail('${template.tplName}');">
				<c:out value="${template.tplName}"/>
				</a>
			</td>
			<td>
				<c:out value="${template.tplSource}"/>
			</td>
			<td>
				<c:out value="${template.lastModified}"/>
			</td>
			<td>
				<c:out value="${template.isDirectory}"/>
			</td>
		</tr>
		</c:forEach>
	</table>
	
	<div>
	<c:set var="paging" value="${templateCriteria.paging}"/>
	<%@ include file="/WEB-INF/jsp/include/paging/default.jsp"%>
	</div>
	
	<p/>
	
	<a href="<c:url value='javascript:goWrite();'/>">write</a>
	<a href="<c:url value='/template.do'/>">list</a>

</body>
</html>
